import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import {AtTag, AtAvatar } from 'taro-ui'
import './wujianxiTeam.scss'
import touxiang from '../../img/touxiang.png'
import app from '../../main.js'

export default class WujianxiTeam extends Component {

    config = {
        navigationBarTitleText: '吴建喜的医生团队'
    }
    constructor() {
        super(...arguments)
        this.state = {
            docTean: [
            ]

        }
    }
    handleXieShi(docId,teamTitle) {
        app.navigateTo('../wujianxiTeamInfo/wujianxiTeamInfo'+'?id='+docId+'&title='+teamTitle);
    }
    offect = 0;
    length = 0;
    total = 0;
    isFinlsh = false;

    //上拉加载
    onReachBottom() {
        if ((this.offect + this.length < this.total)) {
            app.toast('正在加载----')
            this.offect = this.offect + this.length;
            this.isFinlsh = false;
            //调用接口
            this.getDate();
        } else {
            app.toast('没有更多数据了咯')
            this.isFinlsh = true;
        }
    }
    getDate() {
        let me = this
        let data = { token: '', offect: this.offect, length: this.length, id: this.$router.params.id }
        app.get('json/liangguan/docTeam.json', data, function (res) {
            let docArray = res.data.result.list
            docArray.concat(res.data.result.list)
            me.total  = res.data.total
            me.setState({
                docTean: docArray
            })
        })
    }
    componentDidMount(){
        this.getDate()
    }

    render() {
        let docTeanInfo = this.state.docTean.map((docTeam) => {
            return  <View className='box' onClick={this.handleXieShi.bind(this,docTeam.id,docTeam.title)}>
                        <View className='title'>
                            {docTeam.title}
                        </View>
                        <View className='content'>
                            <View className='info'>
                                <View className='image'>
                                    <View>
                                        <AtAvatar
                                            customStyle="height:40px; width:40px;"
                                            image={docTeam.head_image}
                                            circle
                                        />
                                    </View>
                                    <View>
                                        <AtTag
                                            className='tag'
                                            type=''
                                            circle
                                            size='small'
                                        >
                                            {docTeam.head}
                                        </AtTag>
                                    </View>
                                </View>
                                <View>
                                    <View><Text className='name'>{docTeam.name}</Text>{docTeam.positional_title}</View>
                                    <View className='t3'><Text>{docTeam.hospital}</Text></View>
                                </View>
                            </View>
                            <View className='textDire'>
                                <Text> 团队擅长：{docTeam.speciality}</Text>
                            </View>
                        </View>
                    </View>

        })
        return (
            <View>
                {docTeanInfo}
            </View>
        )
    }
}
